﻿using System.Collections.ObjectModel;
using Monti.MVVM;

namespace SqliteHelper.Classes
{
   /// <summary>
   /// Represents the new table dialog's data.
   /// </summary>
   public class SqliteTableViewModel : DialogBase
   {
      private string m_TxtName;
      private bool m_BoolIsNameReadOnly;

      /// <summary>
      /// Initializes a new table object view model.
      /// </summary>
      public SqliteTableViewModel ()
      {
         this.Width = 400;
         this.Height = 300;
         this.Columns = new ObservableCollection <SqliteColumn> ();
      }

      /// <summary>
      /// Gets the list of columns to create.
      /// </summary>
      public ObservableCollection<SqliteColumn> Columns { get; private set; }

      /// <summary>
      /// Gets or Sets the name of the table.
      /// </summary>
      public string Name
      {
         get { return this.m_TxtName; }
         set
         {
            this.m_TxtName = value;
            this.RaisePropertyChanged ("Name");
         }
      }

      /// <summary>
      /// Gets or Sets if name of the table is readonly.
      /// </summary>
      public bool IsNameReadOnly
      {
         get { return this.m_BoolIsNameReadOnly; }
         set
         {
            this.m_BoolIsNameReadOnly = value;
            this.RaisePropertyChanged ("IsReadOnly");
         }
      }

      /// <summary>
      /// Checks if the ok command can execute.
      /// </summary>
      /// <returns>If it is ok to execute.</returns>
      public override bool CanOkExecute ()
      {
         return !string.IsNullOrEmpty (this.Name);
      }
   }
}
